package com.jackrain.nea.clould.dao;

import com.jackrain.nea.clould.model.CloudErrorModel;
import com.jackrain.nea.clould.model.ThirdLogModel;
import com.jackrain.nea.util.Tools;
import com.jackrain.nea.web.query.QueryEngine;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.sql.Timestamp;

/**
 * 错误日志
 */
@Slf4j
@Component
public class ThirdLogDao {


    public int insert(ThirdLogModel thirdLogModel) throws Exception {

        if (thirdLogModel.getId() <= 0) {
            thirdLogModel.setId(Tools.getInt(com.jackrain.nea.core.db.Tools.getSequence("oms_thirdlog"), 0));
        }

        String sql = "insert into oms_thirdlog" +
                "(id,ad_client_id,oms_plantid,apiurl," +
                "parm,callbackinfo," +
                "ownerid,modifierid,creationdate,modifieddate,isactive)" +
                "values(?,?,?,?," +
                "?,?," +
                "?,?,?,?,?) ";

        Timestamp time = new Timestamp(System.currentTimeMillis());

        int ret = QueryEngine.getInstance().executeUpdate(sql, new Object[]{
                thirdLogModel.getId(), thirdLogModel.getAd_client_id(), thirdLogModel.getOms_plantid(), thirdLogModel.getApiurl(),
                thirdLogModel.getParm(), thirdLogModel.getCallbackinfo(),
                893, 893, time, time, "Y"});


        return ret;

    }



}
